import http from '@/http/http'
import {
    CustcareListParam,
    SaveVisitorDetail,
    SetMsgReadParam,
    TrailNewCustcare,
    VisitorIpBlack,
    VisitorListParam,
    VisitorParam,
    VisitorTalkParam
} from './VisitorModel'

enum Api {
    getList = '/api/v1/visitor/getList',
    getDetail = '/api/v1/visitor/visitor',
    getTalkList = '/api/v1/visitor/talkList',
    setMsgRead = '/api/v1/visitor/set_msg_read',
    updateDetail = '/api/v1/visitor/detail',
    ipBlack = '/api/v1/visitor/ipblack',
    getUnreadMsgCount = '/api/v1/visitor/unread_msg_count',
    getTrailList = '/api/v1/visitor/getTrailList',
    getCustcareList = '/api/v1/visitor/getCustcareList',
    trailNewCustcare = '/api/v1/visitor/trailNewCustcare'
}

// 获取客户列表
export const getVisitorTableApi = async (param: VisitorListParam) => {
    return await http.get(Api.getList, param)
}

// 获得客户详情
export const getVisitorDetailApi = async (param: VisitorParam) => {
    return await http.getRestApi(Api.getDetail, param)
}

// 获得在线访客/已接访客
export const getVisitorTalkApi = async (param: VisitorTalkParam) => {
    return await http.get(Api.getTalkList, param)
}

// 设置消息为已读
export const setMsgReadApi = async (param: SetMsgReadParam) => {
    return await http.post(Api.setMsgRead, param)
}

// 修改访客信息
export const updateDetailApi = async (param: SaveVisitorDetail) => {
    return await http.put(Api.updateDetail, param)
}

// 黑名单操作
export const ipBlackApi = async (param: VisitorIpBlack) => {
    return await http.post(Api.ipBlack, param)
}

// 获得未读消息数量
export const getUnreadMsgCountApi = async () => {
    return await http.get(Api.getUnreadMsgCount)
}

// 获得访客的轨迹
export const getTrailListApi = async (param: VisitorParam) => {
    return await http.get(Api.getTrailList, param)
}

// 获得在线客服列表
export const getCustcareListApi = async (param: CustcareListParam) => {
    return await http.get(Api.getCustcareList, param)
}

// 转接到新的客服
export const trailNewCustcareApi = async (param: TrailNewCustcare) => {
    return await http.post(Api.trailNewCustcare, param)
}
